'use strict'

import {app} from 'electron'
// 执行windowManager.js
import initWindow from './services/windowManager'
import electronDevtoolsInstaller, {VUEJS_DEVTOOLS} from 'electron-devtools-installer'


function onAppReady() {
    initWindow()
    if (process.env.NODE_ENV === 'development') {
        electronDevtoolsInstaller(VUEJS_DEVTOOLS)
            .then((name) => console.log(`installed: ${name}`))
            .catch(err => console.log('Unable to install `vue-devtools`: \n', err))
    }
}

//禁止程序多开，此处需要单例锁的同学打开注释即可
// const gotTheLock = app.requestSingleInstanceLock()
// if(!gotTheLock){
//   app.quit()
// }
app.isReady() ? onAppReady() : app.on('ready', onAppReady)

app.on('window-all-closed', () => {
    // 所有平台均为所有窗口关闭就退出软件
    app.quit()
})
app.on('browser-window-created', () => {
    console.log('window-created')
})

if (process.defaultApp) {
    if (process.argv.length >= 2) {
        app.removeAsDefaultProtocolClient('electron-vue-template')
    }
} else {
    app.setAsDefaultProtocolClient('electron-vue-template')
}
